how to multiply vector and matrix
Ältere Kommentare anzeigen
Hello there,
i need your help. i got two question
1. i have a :
col=1;
t=0:(1.5/10):1.5;
for i=1:length(t)
if col<11
m1=magnitudeL(1,col);
m2=magnitudeL(1,col+1);
m3=m2-m1;
acceL(1,col)=[m3/((1.5/10).^2)];
end
col=col+1;
end
how can i plot the graph of plot(t,accel) ? everytime its return error =
Error using plot Vectors must be the same lengths.
i understand the array not same, but i can't modify * acceL * to be same as t.
2. i have a
Lversor=[x;seatoff;z];
i need this vector to multiply with f and M .i.e :
forceMa=m*acceL*Lversor;
where m is a constant and acceL is an array.acceL is same like coding above. is it posible to do that?
thank you.
2 Kommentare
Roger Stafford
am 24 Dez. 2014
In 1. how would you suggest a plot be made using more 't' values than 'acceL' values, namely 11 against only 10? What would such a plot look like?
In 2. where you write "m*acceL*Lversor" the second asterisk sign is understood in matlab to be matrix multiplication, and this always requires that the number of columns in 'acceL' be the same as the number of rows in 'Lversor'. Otherwise Matlab will always give you an error message. I suggest you specify precisely what numerical computations you want to see used to obtain 'forceMa' without using matlab syntax and see if we can come up with an algorithm that accomplishes it.
m
am 25 Dez. 2014
Antworten (1)
Image Analyst
am 24 Dez. 2014
Try this:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
numberOfElements = 11; % Whatever.
magnitudeL = rand(1,numberOfElements) % Sample data
t= linspace(0, 1.5, numberOfElements)
acceL = zeros(1, numberOfElements-1);
for k = 1 : numberOfElements-1
m1 = magnitudeL(1,k);
m2 = magnitudeL(1,k+1);
m3 = m2 - m1;
acceL(k) = m3 / ((1.5/10).^2);
end
plot(t, magnitudeL, 'bo-');
grid on;
hold on;
plot(t(1:length(acceL)), acceL, 'rd-');
3 Kommentare
m
am 25 Dez. 2014
Image Analyst
am 25 Dez. 2014
acceL is one element shorter than t so I can't plot it vs. t - I have to plot it versus all but the last element of t, which is what t(1:length(acceL)) gives me. 'r' meand red. 'd' means diamond. '-' means to put a solid line between the data points.
m
am 30 Dez. 2014
Kategorien
Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!