Error using mpower inputs must be a scalar and a square matrix

Как исправить ошибку using ==> mpower Matrix must be square Matlab Решение и ответ на вопрос 1529759

Slavador

3 / 3 / 0

Регистрация: 26.09.2014

Сообщений: 84

1

13.09.2015, 11:46. Показов 7504. Ответов 5

Метки нет (Все метки)


Последняя строка выдает ошибку

Matlab M
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
%Task1%
x=1;
y=1;
 
z = (1 + asin(cos(2*y)))/(2^(x)+3^(-x))+((2^(x)+3^(-x)-1)/(1 + asin(cos(2*y))))^2
 
%Task2%
x = 0.48;
b = -0.31;
c = 1.72;
a = 2.01;
k = 3;
y1 = (abs(a*x^(2)-b^(3)))^(1/5)+ log(k*x)- (exp(x*k)+c^(2))/sin(k*x) - 10^(-3)* 2157^(1/2)
 
 
%Task3%
x=0.48:0.1:5.38; 
y1 = (abs(a*x^(2)-b^(3)))^(1/5)+ log(k*x)- (exp(x*k)+c^(2))/sin(k*x) - 10^(-3)* 2157^(1/2)

Добавлено через 18 минут
Я понимаю, что нужно ставить точки перед степенями. Но как определить, перед какими?
Также, как определить перед какими делениями нужно ставить точку?
Если можно — простыми словами)

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь



0



Programming

Эксперт

94731 / 64177 / 26122

Регистрация: 12.04.2006

Сообщений: 116,782

13.09.2015, 11:46

5

Krasme

6513 / 4646 / 1932

Регистрация: 02.02.2014

Сообщений: 12,478

13.09.2015, 11:57

2

СЕКРЕТНО! Зловещая точка претыкания

Добавлено через 6 минут

Matlab M
1
y1=(abs(a*x.^(2)-b^(3))).^(1/5)+ log(k*x)- (exp(x*k)+c^(2))/sin(k*x) - 10^(-3)* 2157^(1/2)



1



3 / 3 / 0

Регистрация: 26.09.2014

Сообщений: 84

13.09.2015, 12:01

 [ТС]

3

Еще нужно где-то перед делением ставить, а то все 50 ответов одинаковые. И если не сложно, можешь объяснить логику, как ты определил перед какими именно возведениями ставить «.»?



0



Krasme

6513 / 4646 / 1932

Регистрация: 02.02.2014

Сообщений: 12,478

13.09.2015, 12:08

4

Matlab M
1
y1=(abs(a*x.^(2)-b^(3))).^(1/5)+ log(k*x)- (exp(x*k)+c^(2))./sin(k*x) - 10^(-3)* 2157^(1/2)

Цитата
Сообщение от Slavador
Посмотреть сообщение

как ты определил перед какими именно возведениями ставить

как новичку, рекомендую поступать поэтапно…
сначала

Matlab M
1
(abs(a*x^(2)-b^(3)))^(1/5)

затем

Matlab M
1
(abs(a*x^(2)-b^(3)))^(1/5)+ log(k*x)

и напоследок

Matlab M
1
(abs(a*x^(2)-b^(3)))^(1/5)+ log(k*x)- (exp(x*k)+c^(2))/sin(k*x)

разобравшись с каждым этапом, определитесь с точками



1



3 / 3 / 0

Регистрация: 26.09.2014

Сообщений: 84

13.09.2015, 12:34

 [ТС]

5

Методом тыка то получается, просто интересно какой логикой нужно руководствоваться, чтобы сразу понимать, где ставить



0



6513 / 4646 / 1932

Регистрация: 02.02.2014

Сообщений: 12,478

13.09.2015, 12:41

6



0



Roman5000

Пользователь
Сообщения: 13
Зарегистрирован: Сб окт 04, 2008 4:43 pm

График

Здраствуйте. Не выходит построить график функции. Я записываю так

>> x=5:0.1:25;

>> y=(((log(x))^2)-5*log(x)+6);

??? Error using ==> mpower

Matrix must be square.


Roman5000

Пользователь
Сообщения: 13
Зарегистрирован: Сб окт 04, 2008 4:43 pm

Сообщение Roman5000 » Сб окт 04, 2008 5:05 pm

А если вести логарифм в степени 2 просто как умножить два раза то выдает другую ошибку

>> x=5:1:25;

>> y=(log(x)*log(x)-5*log(x)+6);

??? Error using ==> mtimes

Inner matrix dimensions must agree.


sandy

Эксперт
Сообщения: 5601
Зарегистрирован: Ср сен 22, 2004 4:49 pm

Сообщение sandy » Сб окт 04, 2008 5:07 pm

Операции должны быть поэлементными, а не векторными:

y=(log(x).*log(x)-5*log(x)+6);

С уважением

Александр Сергиенко


Roman5000

Пользователь
Сообщения: 13
Зарегистрирован: Сб окт 04, 2008 4:43 pm

Сообщение Roman5000 » Сб окт 04, 2008 5:11 pm

Спасибо а что это значит? как это задается? тоесть вы просто поставили точку после логарифма ?



Roman5000

Пользователь
Сообщения: 13
Зарегистрирован: Сб окт 04, 2008 4:43 pm

Сообщение Roman5000 » Сб окт 04, 2008 11:49 pm

Еще такой вопрос — меняю парметры Х, а график от этого не меняется, тоесть к примеру

x=-10:1:10; или x=-100:1:100; а выводит график от 0 до 250 в любом случае…. как это можно изменить?


Di@blo

Пользователь
Сообщения: 115
Зарегистрирован: Вт мар 04, 2008 8:34 am

Сообщение Di@blo » Вс окт 05, 2008 6:18 am

Roman5000 писал(а):Еще такой вопрос — меняю парметры Х, а график от этого не меняется, тоесть к примеру
x=-10:1:10; или x=-100:1:100; а выводит график от 0 до 250 в любом случае…. как это можно изменить?

А игрик пересчитвешь? или просто пишешь

x=-10:1:10;

plot(y);

??

____________________

…изобретает, не тот, кто знает, что это не возможно, а тот, кто этого не знает…

ICQ 438225453


Roman5000

Пользователь
Сообщения: 13
Зарегистрирован: Сб окт 04, 2008 4:43 pm

Сообщение Roman5000 » Вс окт 05, 2008 12:27 pm

да, просто пишу плот у


Di@blo

Пользователь
Сообщения: 115
Зарегистрирован: Вт мар 04, 2008 8:34 am

Сообщение Di@blo » Вс окт 05, 2008 1:14 pm

Roman5000 писал(а):да, просто пишу плот у

напиши так

x=-10:.1:10;

y=(log(x).*log(x)-5*log(x)+6);

plot(y);

у меня работает)

____________________

…изобретает, не тот, кто знает, что это не возможно, а тот, кто этого не знает…

ICQ 438225453



Ромашка

Пользователь
Сообщения: 2
Зарегистрирован: Пт май 14, 2010 9:05 pm

Сообщение Ромашка » Пт май 14, 2010 9:17 pm

у меня похожая проблема

я имею функцию f(t)=G(1,1)*(t^2)+G(2,1)*t+G(3,1);

и мену тоже выдаёт Error using ==> mpower

Matrix must be square..


Jey

Пользователь
Сообщения: 2714
Зарегистрирован: Вт сен 12, 2006 2:21 pm

Сообщение Jey » Пт май 14, 2010 9:26 pm

Код: Выделить всё

t=1:5;
G=ones(3,1);
f=G(1,1)*(t.^2)+G(2,1)*t+G(3,1);


Ромашка

Пользователь
Сообщения: 2
Зарегистрирован: Пт май 14, 2010 9:05 pm

Сообщение Ромашка » Пт май 14, 2010 9:59 pm

Jey писал(а):

Код: Выделить всё

t=1:5;
G=ones(3,1);
f=G(1,1)*(t.^2)+G(2,1)*t+G(3,1);

спасибо я понял свою ошибку

помог! :!:


aliis

Пользователь
Сообщения: 1
Зарегистрирован: Пт апр 20, 2012 3:06 am

Сообщение aliis » Пт апр 20, 2012 3:09 am

Возникла проблема

>> y=2^(2*cos(x)-x.^2)+sin(pi/2-x)-x.^2;

??? Error using ==> mpower

Inputs must be a scalar and a square matrix.

Не могу понять ошибку.


abobroff

Пользователь
Сообщения: 488
Зарегистрирован: Пн окт 25, 2010 1:21 pm

Сообщение abobroff » Пт апр 20, 2012 7:16 am

aliis писал(а):Возникла проблема
>> y=2^(2*cos(x)-x.^2)+sin(pi/2-x)-x.^2;
??? Error using ==> mpower
Inputs must be a scalar and a square matrix.


Содержание

  1. Why do I get the error message ‘Matrix must be square.’ ?
  2. Direct link to this question
  3. Direct link to this question
  4. Accepted Answer
  5. Direct link to this answer
  6. Direct link to this answer
  7. Direct link to this comment
  8. Direct link to this comment
  9. Direct link to this comment
  10. Direct link to this comment
  11. More Answers (0)
  12. See Also
  13. Categories
  14. Products
  15. Community Treasure Hunt
  16. How to Get Best Site Performance
  17. Americas
  18. Europe
  19. Asia Pacific
  20. Matrix must be square error.
  21. Direct link to this question
  22. Direct link to this question
  23. Direct link to this comment
  24. Direct link to this comment
  25. Answers (1)
  26. Direct link to this answer
  27. Direct link to this answer
  28. See Also
  29. Categories
  30. Community Treasure Hunt
  31. How to Get Best Site Performance
  32. Americas
  33. Europe
  34. Asia Pacific
  35. Why do I get the error message ‘Matrix must be square.’ ?
  36. Direct link to this question
  37. Direct link to this question
  38. Accepted Answer
  39. Direct link to this answer
  40. Direct link to this answer
  41. Direct link to this comment
  42. Direct link to this comment
  43. Direct link to this comment
  44. Direct link to this comment
  45. More Answers (0)
  46. See Also
  47. Categories
  48. Products
  49. Community Treasure Hunt
  50. How to Get Best Site Performance
  51. Americas
  52. Europe
  53. Asia Pacific
  54. Error using ==> mpower, Matrix must be square
  55. Direct link to this question
  56. Direct link to this question
  57. Answers (1)
  58. Direct link to this answer
  59. Direct link to this answer
  60. Direct link to this comment
  61. Direct link to this comment
  62. See Also
  63. Categories
  64. Community Treasure Hunt
  65. How to Get Best Site Performance
  66. Americas
  67. Europe
  68. Asia Pacific
  69. Squareing Matrix(?) in MATLAB
  70. Answers and Replies

Why do I get the error message ‘Matrix must be square.’ ?

Direct link to this question

Direct link to this question

Accepted Answer

Direct link to this answer

Direct link to this answer

2 Comments

More Answers (0)

See Also

Categories

No tags entered yet.

Products

Find the treasures in MATLAB Central and discover how the community can help you!

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Americas

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
    • 简体中文 Chinese
    • English
  • 日本 Japanese (日本語)
  • 한국 Korean (한국어)

Accelerating the pace of engineering and science

MathWorks is the leading developer of mathematical computing software for engineers and scientists.

Источник

Matrix must be square error.

Direct link to this question

Direct link to this question

1 Comment

Answers (1)

Direct link to this answer

Direct link to this answer

0 Comments

See Also

Categories

Find the treasures in MATLAB Central and discover how the community can help you!

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Americas

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
    • 简体中文 Chinese
    • English
  • 日本 Japanese (日本語)
  • 한국 Korean (한국어)

Accelerating the pace of engineering and science

MathWorks is the leading developer of mathematical computing software for engineers and scientists.

Источник

Why do I get the error message ‘Matrix must be square.’ ?

Direct link to this question

Direct link to this question

Accepted Answer

Direct link to this answer

Direct link to this answer

2 Comments

More Answers (0)

See Also

Categories

No tags entered yet.

Products

Find the treasures in MATLAB Central and discover how the community can help you!

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Americas

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
    • 简体中文 Chinese
    • English
  • 日本 Japanese (日本語)
  • 한국 Korean (한국어)

Accelerating the pace of engineering and science

MathWorks is the leading developer of mathematical computing software for engineers and scientists.

Источник

Error using ==> mpower, Matrix must be square

Direct link to this question

Direct link to this question

0 Comments

Answers (1)

Direct link to this answer

Direct link to this answer

1 Comment

See Also

Categories

Find the treasures in MATLAB Central and discover how the community can help you!

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Americas

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
    • 简体中文 Chinese
    • English
  • 日本 Japanese (日本語)
  • 한국 Korean (한국어)

Accelerating the pace of engineering and science

MathWorks is the leading developer of mathematical computing software for engineers and scientists.

Источник

Squareing Matrix(?) in MATLAB

Hello, I’ve got quick questions.
1. When I have a matrix, x, and try to get different values for each x (given y = (x^2)+b),
I get this error.

? Error using ==> mpower
Matrix must be square.

2. x is [1×101] double according to MATLAB and I’ve had this problem when I was taking derivative as well. I’ve lost numbers throughout the derivative, which i understands.
so x’ = [1×100] and x» = [1×99] and so forth.

What’s the best way to solve these problems.
Thank you.

Answers and Replies

Hello, I’ve got quick questions.
1. When I have a matrix, x, and try to get different values for each x (given y = (x^2)+b),
I get this error.

? Error using ==> mpower
Matrix must be square.

2. x is [1×101] double according to MATLAB and I’ve had this problem when I was taking derivative as well. I’ve lost numbers throughout the derivative, which i understands.
so x’ = [1×100] and x» = [1×99] and so forth.

What’s the best way to solve these problems.
Thank you.

>> x=sqrt(500/105);
>> a=[0:0.1:100];
>> b=[0:1:100];
>> z=a/(2*(sqrt(3000*15)));
>> p=x(sqrt(1-((z)^2)))
? Error using ==> mpower
Matrix must be square.

this is not the direct problem but it’s basically the same thing.
Why am I getting this error?

I will hold onto my second question for now.

[edit] another question.

>> x=A*(exp(-(z*wn*t)))*(sin(wd*t))
? Error using ==> mtimes
Inner matrix dimensions must agree.

everything is numeric except t is in matrix.

>> x=sqrt(500/105);
>> a=[0:0.1:100];
>> b=[0:1:100];
>> z=a/(2*(sqrt(3000*15)));
>> p=x(sqrt(1-((z)^2)))
? Error using ==> mpower
Matrix must be square.

this is not the direct problem but it’s basically the same thing.
Why am I getting this error?

It looks like you are using the matrix power operator ^ where you should be using the array power operator .^ . The matrix power operator A^n multiplies the matrix A by itself n times, which means the number of columns in A must be equal to the number of rows in A, which means that A must be square (size(A) = [m x m] for some positive integer m). The array power operator A.^n raises each element of A to the nth power, and therefore has no restrictions on the dimensions of A.

>> x=A*(exp(-(z*wn*t)))*(sin(wd*t))
? Error using ==> mtimes
Inner matrix dimensions must agree.

everything is numeric except t is in matrix.

Источник

Понравилась статья? Поделить с друзьями:
  • Error using loadlibrary matlab
  • Error using inner matrix dimensions must agree перевод
  • Error using inner matrix dimensions must agree матлаб
  • Error using inline subsref line 12 not enough inputs to inline function
  • Error using imhist expected input number 1 i or x to be two dimensional